const request = require("../utils/request")

/**
 * 获取地址列表
 *
 * @returns {Promise<unknown>}
 */
export const getAddress = () =>request.get('/api/address')

/**
 * 添加地址
 *
 * @param data
 * @returns {Promise<unknown>}
 */
export const addAddress = (data) =>request.post('/api/address',data)

/**
 * 查看地址详情
 *
 * @returns {Promise<unknown>}
 */
export const getAddressInfo = (id) =>request.get('/api/address/' + id)

/**
 * 修改地址
 *
 * @returns {Promise<unknown>}
 */
export const updateAddress = (id,data)=>request.put('/api/address/' + id,data)

/**
 * 删除地址
 * @param id
 * @returns {Promise<unknown>}
 */
export const deleteAddress = (id) =>request.delete('/api/address/' + id)

/**
 * 设置为默认
 * @param id  地址id
 * @returns {Promise<unknown>}
 */
export const setDefault = (id) =>request.patch('/api/address/' + id + '/default')